home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-10 | 8.2 KB | 275 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CActiveXShadowView.cpp ©1996 Microsoft Corporation. All rights reserved.
- // ===========================================================================
- //
- // manages an active x control
-
- #ifdef PowerPlant_PCH
- #include PowerPlant_PCH
- #endif
-
- #include "ActiveXAppConstants.h"
- #include "CActiveXDocument.h"
- #include "CActiveXView.h"
- #include "CActiveXShadowView.h"
- #include "CArgumentParser.h"
- #include <LStream.h>
- #include <UDrawingState.h>
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #include "HEADERS.H"
-
- #pragma mark === CActiveXShadowView::Construction & Destruction ===
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::CreateActiveXShadowViewStream [static]
- // ---------------------------------------------------------------------------
- // Return a new Picture object initialized using data from a Stream
-
- CActiveXShadowView*
- CActiveXShadowView::CreateActiveXShadowViewStream(
- LStream *inStream)
- {
- return (new CActiveXShadowView(inStream));
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::CActiveXShadowView
- // ---------------------------------------------------------------------------
- // Default Constructor
-
- CActiveXShadowView::CActiveXShadowView() : LDragAndDrop(UQDGlobals::GetCurrentPort(), this)
- {
- mMasterView = NULL;
- mMasterViewID = 0;
- mContextDirty = false;
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::CActiveXShadowView(LStream*)
- // ---------------------------------------------------------------------------
- // Construct shadow view from the data in a Stream
-
- CActiveXShadowView::CActiveXShadowView(
- LStream *inStream)
- : LView(inStream), LDragAndDrop(UQDGlobals::GetCurrentPort(), this)
- {
- mMasterView = NULL;
- mMasterViewID = 0;
- mContextDirty = false;
-
- inStream->ReadData(&mMasterViewID, sizeof(mMasterViewID));
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::~CActiveXShadowView()
- // ---------------------------------------------------------------------------
- // Destructor
-
- CActiveXShadowView::~CActiveXShadowView(void)
- {
- if ( mMasterView )
- mMasterView->RemoveShadowView( this );
- }
-
-
- #pragma mark === CActiveXShadowView ===
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::DrawSelf
- // ---------------------------------------------------------------------------
- // Draw the shadow view
-
- void
- CActiveXShadowView::DrawSelf()
- {
- if (!mMasterView)
- FindMasterView(this);
-
- if (mMasterView)
- {
- mMasterView->DrawShadowView( this, mContextDirty );
- mContextDirty = false;
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::DoEvent
- // ---------------------------------------------------------------------------
- // Pass events to Active X
-
- void
- CActiveXShadowView::DoEvent(EventRecord *Event, Boolean *PassEventUp, Boolean *RemoveAttachment)
- {
- if (!mMasterView)
- FindMasterView(this);
-
- if (mMasterView)
- mMasterView->DoEvent(Event, PassEventUp, RemoveAttachment);
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::SetMasterView
- // ---------------------------------------------------------------------------
- // Change the master view
-
- void
- CActiveXShadowView::SetMasterView(CActiveXView *inMasterView)
- {
- mMasterView = inMasterView;
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::FindMasterView [static]
- // ---------------------------------------------------------------------------
- // find the containing window
-
- void
- CActiveXShadowView::FindMasterView(CActiveXShadowView* inView)
- {
- LView *CurrentView = inView;
- LView *NextView;
-
- while ((NextView = CurrentView->GetSuperView()) != NULL)
- CurrentView = NextView;
-
- inView->mMasterView = (CActiveXView *) CurrentView->FindPaneByID( inView->mMasterViewID );
- inView->mMasterView->AddShadowView(inView);
- }
-
-
- #pragma mark === CActiveXShadowView::LView ===
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::Click
- // ---------------------------------------------------------------------------
- // Pass Mouse Click Events to Active X
-
- void
- CActiveXShadowView::Click(SMouseDownEvent &inMouseDown)
- {
- if (!mMasterView)
- FindMasterView(this);
-
- if (mMasterView)
- mMasterView->ClickInShadowView(this, inMouseDown);
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::ResizeFrameBy
- // ---------------------------------------------------------------------------
- // Log self as the active draw context, and pass through the click
-
- void
- CActiveXShadowView::ResizeFrameBy(Int16 inWidthDelta, Int16 inHeightDelta, Boolean inRefresh)
- {
- mContextDirty = true;
- LView::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::MoveBy
- // ---------------------------------------------------------------------------
- // Log self as the active draw context, and pass through the click
-
- void
- CActiveXShadowView::MoveBy(Int32 inHorizDelta, Int32 inVertDelta, Boolean inRefresh)
- {
- mContextDirty = true;
- LView::MoveBy(inHorizDelta, inVertDelta, inRefresh);
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::AdaptToNewSurroundings
- // ---------------------------------------------------------------------------
- // Log self as the active draw context, and pass through the click
-
- void
- CActiveXShadowView::AdaptToNewSurroundings(void)
- {
- mContextDirty = true;
- LView::AdaptToNewSurroundings();
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::AdaptToSuperFrameSize
- // ---------------------------------------------------------------------------
- // Log self as the active draw context, and pass through the click
-
- void
- CActiveXShadowView::AdaptToSuperFrameSize(Int32 inSurrWidthDelta, Int32 inSurrHeightDelta, Boolean inRefresh)
- {
- mContextDirty = true;
- LView::AdaptToSuperFrameSize(inSurrWidthDelta, inSurrHeightDelta, inRefresh);
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::ScrollImageBy
- // ---------------------------------------------------------------------------
- // Log self as the active draw context, and pass through the click
-
- void
- CActiveXShadowView::ScrollImageBy(Int32 inLeftDelta, Int32 inTopDelta, Boolean inRefresh)
- {
- mContextDirty = true;
- LView::ScrollImageBy(inLeftDelta, inTopDelta, inRefresh);
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LView::ResizeImageBy
- // ---------------------------------------------------------------------------
- // Log self as the active draw context, and pass through the click
-
- void
- CActiveXShadowView::ResizeImageBy(Int32 inWidthDelta, Int32 inHeightDelta, Boolean inRefresh)
- {
- mContextDirty = true;
- LView::ResizeImageBy(inWidthDelta, inHeightDelta, inRefresh);
- }
-
-
- #pragma mark === CActiveXView::LDragAndDrop ===
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LDragAndDrop::ItemIsAcceptable
- // ---------------------------------------------------------------------------
- // tell the control about a draw context change
-
- Boolean
- CActiveXShadowView::ItemIsAcceptable( DragReference inDragRef, ItemReference inItemRef )
- {
- if (mMasterView)
- return mMasterView->ItemIsAcceptable(inDragRef, inItemRef);
-
- return false;
- }
-
-
- // ---------------------------------------------------------------------------
- // • CActiveXShadowView::LDragAndDrop::ReceiveDragItem
- // ---------------------------------------------------------------------------
- // tell the control about a draw context change
-
- void
- CActiveXShadowView::ReceiveDragItem( DragReference inDragRef, DragAttributes inDragAttrs,
- ItemReference inItemRef, Rect &inItemBounds)
- {
- if (mMasterView)
- mMasterView->ReceiveDragItem(inDragRef, inDragAttrs, inItemRef, inItemBounds);
- }
-